import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/base/widget/defult_widget.dart';
import 'package:dmz/business/home/controller/code_scan_result_controller.dart';
import 'package:dmz/business/home/model/moto_model.dart';
import 'package:dmz/business/login/widgets/login_widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class CodeScanResultPage extends BaseStatefulWidget<CodeScanResultRontroller> {
  const CodeScanResultPage({super.key});

  @override
  bool showTitleBar() => true;

  @override
  String titleString() => '扫描结果'.tr;

  @override //背景渐变色
  LinearGradient? linearGradient() => const LinearGradient(
      begin: Alignment.topCenter,
      end: Alignment.bottomCenter,
      colors: [Color(0xFF313132), Color(0xFF292A31), Color(0xFF2C2D35)]);

  @override
  Widget buildContent(BuildContext context) {
    return Column(children: [
      Container(
          height: 2.sp,
          decoration: const BoxDecoration(
              gradient: LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [Color(0xFF6DD400), Color(0xFF20C468)],
          ))),
      Obx(() => Expanded(
          child: ListView.builder(
              physics: const NeverScrollableScrollPhysics(),
              itemCount: controller.deviceDatas.length,
              itemBuilder: (context, index) {
                return listItem(controller.deviceDatas[index], context);
              })))
    ]);
  }

  listItem(MotoModel data, context) {
    return Container(
        color: Color(0xFF434650),
        child: Row(children: [
          DefaultNetWorkImage(data.photo ?? '', width: 112.sp, height: 112.sp),
          Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
            DefaultText(data.name ?? '', 48.sp,
                fontWeight: FontWeight.w600, textColor: Colors.white),
            DefaultText(
                '${'车架号后四位'.tr}：${data.frame_code!.substring(data.frame_code!.length - 4)}',
                22.sp,
                textColor: Color(0xFF797A80)),
          ]).paddingOnly(left: 32.sp),
          const Expanded(child: SizedBox()),
          LoginWidgets.loginOtherBtn(context, controller.bindMoto,
              title: '立即绑定'.tr,
              textSize: 28.sp,
              textColor: Colors.white,
              hight: 72.sp,
              width: 200.sp)
        ]).paddingOnly(left: 30.sp, right: 30.sp, top: 40.sp, bottom: 40.sp));
  }
}
